package com.zhazha.earlybird.control;

import java.util.List;

import com.zhazha.earlybird.beans.CampusRecruitInfo;
import com.zhazha.earlybird.beans.CompetitionInfo;
import com.zhazha.earlybird.beans.ParttimeJobInfo;
import com.zhazha.earlybird.entity.CampusRecruitDetailEntity;
import com.zhazha.earlybird.entity.CompetitionDetailEntity;
import com.zhazha.earlybird.entity.MeetingEntity;
import com.zhazha.earlybird.entity.ParttimeJobDetailEntity;
import com.zhazha.earlybird.util.HttpUtil;
import com.zhazha.earlybird.util.JsonUtil;

public class HttpControl {

	private HttpUtil mHttpUtil = new HttpUtil();
	private JsonUtil mJsonUtil = new JsonUtil();
	
	private static final String BASE_URL = "http://www.hdshangye.com/ebs/request/";
	
	//public List<UserEntity> queryUserDataFromServer(String url) {
	//	String str = BASE_URL + "/" + url;
	//	return mJsonUtil.getUserList(mHttpUtil.queryStringForGet(str));
	//}
	
	public List<CampusRecruitInfo> requestCampusRecruitList(int update, 
															int id, int city, int position) {
		String url = "job/list/" + String.valueOf(update) + "/" + String.valueOf(id) + "/" + String.valueOf(city) + "/" + String.valueOf(position);
		
		return mJsonUtil.getCampusRecruitList(mHttpUtil.queryStringForGet(BASE_URL + url));
		
	}
	
	public List<ParttimeJobInfo> requestParttimeJobList(int update,
														int id, int city, int kind) {
		String url = "parttime/list/" + String.valueOf(update) + "/" + String.valueOf(id) + "/" + String.valueOf(city) + "/" + String.valueOf(kind);
		
		return mJsonUtil.getParttimeJobList(mHttpUtil.queryStringForGet(BASE_URL + url)); 
	}
	
	public List<CompetitionInfo> requestCompetitionList(int update,
														int id, int kind) {
		String url = "competition/list/" + String.valueOf(update) + "/" + String.valueOf(id) + "/" + String.valueOf(kind);
		
		return mJsonUtil.getCompetitionList(mHttpUtil.queryStringForGet(BASE_URL + url)); 
	}

	public ParttimeJobDetailEntity requestParttimeJobDetail(int id) {
		
		String url = "parttime/detail/" + String.valueOf(id);
		return mJsonUtil.getParttimeJobDetail(mHttpUtil.queryStringForGet(BASE_URL + url)); 
	}
	
	public CompetitionDetailEntity requestCompetitionDetail(int id) {
		
		String url = "competition/detail/" + String.valueOf(id);
		return mJsonUtil.getCompetitionDetail(mHttpUtil.queryStringForGet(BASE_URL + url));
	}
	
	public CampusRecruitDetailEntity requestCampusRecruitDetail(int id) {
		
		String url = "job/detail/" + String.valueOf(id);
		return mJsonUtil.getCampusRecruitDetail(mHttpUtil.queryStringForGet(BASE_URL + url));
	}
	
	public List<MeetingEntity> requestMeetingList(int id) {
		
		String url = "job/meeting/" + String.valueOf(id);
		return mJsonUtil.getMeetingList(mHttpUtil.queryStringForGet(BASE_URL + url));
	}
	
	
}
